<?php

class AccountHelper extends AppHelper {

    public function hasModule($account, $module_name)  {
        
        foreach($account['Organisation']['Module'] as $module) {
            if( $module['name'] == $module_name ) {
                return true;
            }
        }
        
        return false;
    }
    
    public function smsAccountActive($organisation_id) {
        $account = ClassRegistry::init('ModuleSmsAccount')->find('first', array(
            'conditions' => array(
                'ModuleSmsAccount.organisation_id' => $organisation_id
            ),
            'recursive' => -1
        ));
        
        return $account && $account['ModuleSmsAccount']['active'] == 1;
    }
}

